<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
 <%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
 <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%
	String base = request.getContextPath();
	request.setAttribute("base", base);
%>
<!DOCTYPE html>
<html class="sidebar-mini skin-purple-light wysihtml5-supported">
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
	<script type="text/javascript" src="${base}/resources/js/jquery-3.2.1.min.js"></script>
	<style type="text/css">
		.divcss1{width:300px;height:700px;border: 1px solid #F00;} 
		.divcss2{width:800px;height:700px;border: 1px solid blue;} 
	</style>
	<script type="text/javascript">
		function query(id){
			$.ajax({
				url:"${base}/CommodityController/queryCommodity",
				data:{'id':id},
				type:'post',
				dataType:'json',
				success:function(data){
				    var obj=eval(data);
				    var str="";
				    $(obj).each(function(index) {
		                var commodity = obj[index];
		                str+="<div style='float: left;width: 150px;height: 150px;margin-left: 10px;margin-top: 10px;border: 1px solid blue;'>"+
						"<a href='${base}/CommodityController/selectCommodity?id="+commodity.commodityid+"'><img src='${base}/resources/images/none.jpg'></a><br/>"+
						"<h6><a href='${base}/CommodityController/selectCommodity?id="+commodity.commodityid+"'>"+commodity.commodityname+"</a>&nbsp;价格:"+commodity.commodityprice+"</h6>"+
						"</div>";
		            });
				    $("#divshow").empty().append(str);
				}		
			})
		}
	</script>
</head>
<body>
	<div>
			<form action="${base}/CommodityController/importCommodity" method="post" enctype="multipart/form-data">
				<input type="file"  name="filePath" id="filePath">
				<input type="submit" value="提交">
			</form>
			<a href="${base}/CommodityController/getExcel">生成商品excel</a>
			<a href="${base}/selectShopping">我的购物车</a>
			<a href="${base}/selectOrder?pageNum=0">我的订单</a>
	</div>
	<div>
		
		<div class="divcss1" style="float: left;">
			<c:forEach var="type" items="${commodityListTypeList}">
				<h4><a href="javascript:query(${type.commoditytypeid})">${type.typename}</a></h4>
			</c:forEach>
		</div>
		<div class="divcss2" style="float: left;" id="divshow">
			<c:forEach var="commodity" items="${commodityList}" varStatus="i">	
				<div style="float: left;width: 150px;height: 150px;margin-left: 10px;margin-top: 10px;border: 1px solid blue;">
					<a href="${base}/CommodityController/selectCommodity?id=${commodity.commodityid}"><img src="${base}/resources/images/none.jpg"></a><br/>
					<h6><a href="${base}/CommodityController/selectCommodity?id=${commodity.commodityid}">${commodity.commodityname}</a>&nbsp;价格:${commodity.commodityprice}</h6>
				</div>
			</c:forEach>
		</div>
	</div>
</body>
</html>